<template>
  <el-card shadow="never"
           style="height: 634px;overflow: auto">
    <div slot="header"
         class="clearfix">
      <div class=" flex-between ">
        <div class="flex">
          <div class="line"></div>
          <div class="fontSize16"
               style="font-weight: 700;">用户排名 </div>
        </div>
        <el-radio-group v-model="radio1"
                        @input="changeRadio">
          <el-radio-button label="充值"></el-radio-button>

          <el-radio-button label="消费"></el-radio-button>

        </el-radio-group>
      </div>

    </div>

    <div class="rankingList ">
      <div class="flex-between">
        <div class="font-weight_bold ">
          <span class="font-size_30rpx margin-right_50rpx">排名</span>
          <span class="font-size_30rpx">用户</span>
        </div>
        <div class="flex-between"
             style="width: 43%;">
          <div class="font-weight_bold">
            <span class="font-size_30rpx">充值金额</span>
          </div>
          <div class="font-weight_bold">
            <span class="font-size_30rpx">消费</span>
          </div>

        </div>
      </div>

      <div v-if="list.length">
        <div v-for="(item,index) in list"
             :key="index">
          <div class="flex-start-center margin_10px_0">

            <img v-if="index==0"
                 class="medal"
                 src="../../../../assets/前三/蒙版-2.png"
                 alt="">
            <img v-if="index==1"
                 class="medal"
                 src="../../../../assets/前三/蒙版-1.png"
                 alt="">
            <img v-if="index==2"
                 class="medal"
                 src="../../../../assets/前三/蒙版.png"
                 alt="">
            <div style="width: 35px;text-align: center;"
                 v-if="index!=0&&index!=1&&index!=2">{{index+1}}</div>
            <div class="flex-between margin-left_15px "
                 style="width: 100%;">
              <div class="flex">
                <img class="image"
                     :src="item.avatar"
                     alt="">
                <div class="flex-columns-center width121 margin-left_15px">
                  <span class="font-weight_bold margin-bottom_5px"
                        style="font-size: 15px;">{{item.nickname}}</span>

                  <span style="color: rgb(153, 153, 153);font-size: 12px;text-align: left;">{{item.phone}}
                  </span>
                </div>
              </div>
              <div class="flex-column-end margin-left_30rpx">

                <span style="color: rgb(153, 153, 153);font-size: 12px;text-align: left;">￥{{item.recharge_amount}}
                </span>
              </div>

              <div class="flex-column-end margin-left_30rpx">
                <span class="font-weight_bold margin-bottom_10rpx"
                      style="font-size: 15px;color: rgb(255, 51, 38);">￥{{item.consumption_amount}}</span>

              </div>
            </div>
          </div>
        </div>
      </div>
      <div v-else>
        <!-- 自定义提示文字 -->
        <ele-empty class="flex-column"
                   style="height: 337px"
                   text="哎呀, 还没有数据~" />
      </div>
    </div>

  </el-card>
</template>
	
	<script>
import { use } from 'echarts/core';
import { CanvasRenderer } from 'echarts/renderers';
import { TooltipComponent } from 'echarts/components';
// import VChart from 'vue-echarts';
import 'echarts-wordcloud';
import { wordCloudColor } from 'ele-admin';
import { getWordCloudList } from '@/api/dashboard/analysis';
import { echartsMixin } from '@/utils/echarts-mixin';
import { pageUsers } from '@/api/user/user/index'
use([CanvasRenderer, TooltipComponent]);

export default {

  //   components: { VChart },
  mixins: [echartsMixin(['hotSearchChart'])],
  data () {
    const cityOptions = ['充值', '消费'];
    return {
      // 词云图表配置
      hotSearchChartOption: {},
      cities: cityOptions,

      list: [],
      radio1: '充值',
      selsetUserList: ['recharge_amount', 'consumption_amount',]
    };
  },

  activated () {
    this.getPageUsers(0)
  },
  methods: {
    // 获取用户列表
    async getPageUsers (index) {
      const res = await pageUsers({
        field: this.selsetUserList[index]
      })
      console.log(res)

      this.list = res.list

    },
    changeList (val) {
      console.log(val)
    },
    changeRadio (e) {
      console.log(e)
      if (e == '充值') {
        this.getPageUsers(0)
      } else if (e == '消费') {
        this.getPageUsers(1)
      }
    },
    /* 获取词云数据 */
    getWordCloudData () {
      getWordCloudList()
        .then((data) => {
          this.hotSearchChartOption = {
            tooltip: {
              show: true,
              confine: true,
              borderWidth: 1
            },
            series: [
              {
                type: 'wordCloud',
                width: '100%',
                height: '100%',
                sizeRange: [12, 24],
                gridSize: 6,
                textStyle: {
                  color: wordCloudColor
                },
                emphasis: {
                  textStyle: {
                    shadowBlur: 8,
                    shadowColor: 'rgba(0, 0, 0, .15)'
                  }
                },
                data: data
              }
            ]
          };
        })
        .catch((e) => {
          this.$message.error(e.message);
        });
    }
  }
};
</script>
<style lang="less" scoped>
.rankingList {
  border-radius: 10px;
  margin-top: -10px;
  padding: 26px 11px;
  background: rgb(255, 255, 255);

  .medal {
    width: 35px;
    height: 35px;
  }

  .image {
    width: 40px;
    height: 40px;
    margin: 0 10px;
    border-radius: 50%;
  }
  .width121 {
    width: 121px !important;
  }
}
.line {
  width: 4px;
  height: 25px;
  margin-right: 5px;
  background: rgb(90, 158, 247);
}
.fourPalaceGrid {
  display: flex;
  flex-wrap: wrap;
  .singlePalaceGrid {
    .icon {
      width: 52px;
      height: 52px;
    }
    flex: 33.3%; /*0 不放大  0 不收缩  子项大小为父容器25%*/

    height: 93px;

    align-items: center;
    box-sizing: border-box;

    // border: 1px solid #f5f6fb;
    .accumulateNum {
      height: 62px;
      display: flex;
      flex-direction: column;
      justify-content: space-evenly;
      .Num {
        color: #1e6ceb;
        font-size: 20px;
      }
    }
  }
  .icon {
    width: 32px;
    height: 32px;
  }
}
</style>

	